home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / godelqc5.zip / ITEMS.QC < prev    next >
Text File  |  1996-09-16  |  30KB  |  1,358 lines

  1. //float to make possible upgraded weapons
  2. .float weaponnum;
  3.  
  4. void() W_SetCurrentAmmo;
  5. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  6. BE .8 .3 .4 IN COLOR */
  7.  
  8.  
  9. void() SUB_regen =
  10. {
  11.     self.model = self.mdl;          // restore original model
  12.     self.solid = SOLID_TRIGGER;     // allow it to be touched again
  13.     sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  14.     setorigin (self, self.origin);
  15. };
  16.  
  17.  
  18.  
  19. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  20. prints a warning message when spawned
  21. */
  22. void() noclass =
  23. {
  24.     dprint ("noclass spawned at");
  25.     dprint (vtos(self.origin));
  26.     dprint ("\n");
  27.     remove (self);
  28. };
  29.  
  30.  
  31.  
  32. /*
  33. ============
  34. PlaceItem
  35.  
  36. plants the object on the floor
  37. ============
  38. */
  39. void() PlaceItem =
  40. {
  41.     local float     oldz;
  42.  
  43.     self.mdl = self.model;          // so it can be restored on respawn
  44.     self.flags = FL_ITEM;           // make extra wide
  45.     self.solid = SOLID_TRIGGER;
  46.     self.movetype = MOVETYPE_TOSS;  
  47.     self.velocity = '0 0 0';
  48.     self.origin_z = self.origin_z + 6;
  49.     oldz = self.origin_z;
  50.     if (!droptofloor())
  51.     {
  52.         dprint ("Bonus item fell out of level at ");
  53.         dprint (vtos(self.origin));
  54.         dprint ("\n");
  55.         remove(self);
  56.         return;
  57.     }
  58. };
  59.  
  60. /*
  61. ============
  62. StartItem
  63.  
  64. Sets the clipping size and plants the object on the floor
  65. ============
  66. */
  67. void() StartItem =
  68. {
  69.     self.nextthink = time + 0.2;    // items start after other solids
  70.     self.think = PlaceItem;
  71. };
  72.  
  73. /*
  74. =========================================================================
  75.  
  76. HEALTH BOX
  77.  
  78. =========================================================================
  79. */
  80. //
  81. // T_Heal: add health to an entity, limiting health to max_health
  82. // "ignore" will ignore max_health limit
  83. //
  84. float (entity e, float healamount, float ignore) T_Heal =
  85. {
  86.     if (e.health <= 0)
  87.         return 0;
  88.     if ((!ignore) && (e.health >= other.max_health))
  89.         return 0;
  90.     healamount = ceil(healamount);
  91.  
  92.     e.health = e.health + healamount;
  93.     if ((!ignore) && (e.health >= other.max_health))
  94.         e.health = other.max_health;
  95.         
  96.     if (e.health > 250)
  97.         e.health = 250;
  98.     return 1;
  99. };
  100.  
  101. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  102. Health box. Normally gives 25 points.
  103. Rotten box heals 5-10 points,
  104. megahealth will add 100 health, then 
  105. rot you down to your maximum health limit, 
  106. one point per second.
  107. */
  108.  
  109. float   H_ROTTEN = 1;
  110. float   H_MEGA = 2;
  111. .float  healamount, healtype;
  112. void() health_touch;
  113. void() item_megahealth_rot;
  114.  
  115. void() item_health =
  116. {       
  117.     self.touch = health_touch;
  118.  
  119.     if (self.spawnflags & H_ROTTEN)
  120.     {
  121.         precache_model("maps/b_bh10.bsp");
  122.  
  123.         precache_sound("items/r_item1.wav");
  124.         setmodel(self, "maps/b_bh10.bsp");
  125.         self.noise = "items/r_item1.wav";
  126.         self.healamount = 15;
  127.         self.healtype = 0;
  128.     }
  129.     else
  130.     if (self.spawnflags & H_MEGA)
  131.     {
  132.         precache_model("maps/b_bh100.bsp");
  133.         precache_sound("items/r_item2.wav");
  134.         setmodel(self, "maps/b_bh100.bsp");
  135.         self.noise = "items/r_item2.wav";
  136.         self.healamount = 100;
  137.         self.healtype = 2;
  138.     }
  139.     else
  140.     {
  141.         precache_model("maps/b_bh25.bsp");
  142.         precache_sound("items/health1.wav");
  143.         setmodel(self, "maps/b_bh25.bsp");
  144.         self.noise = "items/health1.wav";
  145.         self.healamount = 25;
  146.         self.healtype = 1;
  147.     }
  148.     setsize (self, '0 0 0', '32 32 56');
  149.     StartItem ();
  150. };
  151.  
  152.  
  153. void() health_touch =
  154. {
  155.     local   float amount;
  156.     local   string  s;
  157.     
  158.     if (other.classname != "player")
  159.         return;
  160.     
  161.     if (self.healtype == 2) // Megahealth?  Ignore max_health...
  162.     {
  163.         if (other.health >= 250)
  164.             return;
  165.         if (!T_Heal(other, self.healamount, 1))
  166.             return;
  167.     }
  168.     else
  169.     {
  170.         if (!T_Heal(other, self.healamount, 0))
  171.             return;
  172.     }
  173.     
  174.     sprint(other, "You receive ");
  175.     s = ftos(self.healamount);
  176.     sprint(other, s);
  177.     sprint(other, " health\n");
  178.     
  179. // health touch sound
  180.     sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  181.  
  182.     stuffcmd (other, "bf\n");
  183.     
  184.     self.model = string_null;
  185.     self.solid = SOLID_NOT;
  186.  
  187.     // Megahealth = rot down the player's super health
  188.     if (self.healtype == 2)
  189.     {
  190.         other.items = other.items | IT_SUPERHEALTH;
  191.         self.nextthink = time + 5;
  192.         self.think = item_megahealth_rot;
  193.         self.owner = other;
  194.     }
  195.     else
  196.     {
  197.         if (deathmatch != 2) { // deathmatch 2 is the silly old rules
  198.             if (deathmatch) self.nextthink = time + 20;
  199.             self.think = SUB_regen;
  200.         }
  201.     }
  202.     
  203.     activator = other;
  204.     SUB_UseTargets();                               // fire all targets / killtargets
  205. };      
  206.  
  207. void() item_megahealth_rot =
  208. {
  209.     other = self.owner;
  210.     
  211.     if (other.health > other.max_health)
  212.     {
  213.         other.health = other.health - 1;
  214.         self.nextthink = time + 1;
  215.         return;
  216.     }
  217.  
  218. // it is possible for a player to die and respawn between rots, so don't
  219. // just blindly subtract the flag off
  220.     other.items = other.items - (other.items & IT_SUPERHEALTH);
  221.     
  222.     if (deathmatch!=2 && deathmatch!=0) // deathmatch 2 is silly old rules
  223.     {
  224.         self.nextthink = time + 20;
  225.         self.think = SUB_regen;
  226.     }
  227. };
  228.  
  229. /*
  230. ===============================================================================
  231.  
  232. ARMOR
  233.  
  234. ===============================================================================
  235. */
  236.  
  237. void() armor_touch;
  238.  
  239. void() armor_touch =
  240. {
  241.     local    float    type, value, bit;
  242.     
  243.     if (other.health <= 0)
  244.         return;
  245.     if (other.classname != "player")
  246.         return;
  247.  
  248.     if (self.classname == "item_armor1")
  249.     {
  250.         type = 0.3;
  251.         value = 100;
  252.         bit = IT_ARMOR1;
  253.     }
  254.     if (self.classname == "item_armor2")
  255.     {
  256.         type = 0.6;
  257.         value = 150;
  258.         bit = IT_ARMOR2;
  259.     }
  260.     if (self.classname == "item_armorInv")
  261.     {
  262.         type = 0.8;
  263.         value = 200;
  264.         bit = IT_ARMOR3;
  265.     }
  266. /* Godel qc: armor_touch mods for damaged armor pickup begin
  267. */
  268.     if (self.armortype>0){
  269.         type=self.armortype;
  270.         value=self.armorvalue;
  271.         if (self.armortype==0.3) bit=IT_ARMOR1;
  272.         else if (self.armortype==0.6) bit=IT_ARMOR2;
  273.         else if (self.armortype==0.8) bit=IT_ARMOR3;
  274.     }
  275. /* Godel qc: armor_touch mods for damaged armor pickup end
  276. */ 
  277.     if (other.armortype*other.armorvalue >= type*value)
  278.         return;
  279.     other.armortype = type;
  280.     other.armorvalue = value;
  281.     other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  282.  
  283.     self.solid = SOLID_NOT;
  284.     self.model = string_null;
  285.     if ((deathmatch != 0 && deathmatch!=2) && (self.armorvalue == 0)){
  286.         self.nextthink = time + 20;
  287.         self.think = SUB_regen;
  288.     }
  289.  
  290.     sprint(other, "You got armor\n");
  291. // armor touch sound
  292.     sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  293.     stuffcmd (other, "bf\n");
  294.     
  295.     activator = other;
  296.     SUB_UseTargets();                // fire all targets / killtargets
  297. };
  298.  
  299.  
  300.  
  301. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  302. */
  303.  
  304. void() item_armor1 =
  305. {
  306.     self.touch = armor_touch;
  307.     precache_model ("progs/armor.mdl");
  308.     setmodel (self, "progs/armor.mdl");
  309.     self.skin = 0;
  310.     setsize (self, '-16 -16 0', '16 16 56');
  311.     StartItem ();
  312. };
  313.  
  314. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  315. */
  316.  
  317. void() item_armor2 =
  318. {
  319.     self.touch = armor_touch;
  320.     precache_model ("progs/armor.mdl");
  321.     setmodel (self, "progs/armor.mdl");
  322.     self.skin = 1;
  323.     setsize (self, '-16 -16 0', '16 16 56');
  324.     StartItem ();
  325. };
  326.  
  327. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  328. */
  329.  
  330. void() item_armorInv =
  331. {
  332.     self.touch = armor_touch;
  333.     precache_model ("progs/armor.mdl");
  334.     setmodel (self, "progs/armor.mdl");
  335.     self.skin = 2;
  336.     setsize (self, '-16 -16 0', '16 16 56');
  337.     StartItem ();
  338. };
  339.  
  340. /*
  341. ===============================================================================
  342.  
  343. WEAPONS
  344.  
  345. ===============================================================================
  346. */
  347.  
  348. void() bound_other_ammo =
  349. {
  350.     if (other.ammo_shells > 100)
  351.         other.ammo_shells = 100;
  352.     if (other.ammo_nails > 200)
  353.         other.ammo_nails = 200;
  354.     if (other.ammo_rockets > 100)
  355.         other.ammo_rockets = 100;               
  356.     if (other.ammo_cells > 200)
  357.         other.ammo_cells = 200;         
  358. };
  359.  
  360.  
  361. float(float w) RankForWeapon =
  362. {
  363.     if (w == IT_LIGHTNING)
  364.         return 1;
  365.     if (w == IT_ROCKET_LAUNCHER)
  366.         return 2;
  367.     if (w == IT_SUPER_NAILGUN)
  368.         return 3;
  369.     if (w == IT_SUPER_SHOTGUN)
  370.         return 4;
  371.     if (w == IT_GRENADE_LAUNCHER)
  372.         return 5;
  373.     if (w == IT_NAILGUN)
  374.         return 6;
  375.     return 7;
  376. };
  377.  
  378. /*
  379. =============
  380. Deathmatch_Weapon
  381.  
  382. Deathmatch weapon change rules for picking up a weapon
  383.  
  384. .float          ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  385. =============
  386. */
  387. void(float old, float new) Deathmatch_Weapon =
  388. {
  389.     local float or, nr;
  390.  
  391. // change self.weapon if desired
  392.     or = RankForWeapon (self.weapon);
  393.     nr = RankForWeapon (new);
  394.     if ( nr < or ){
  395.         self.weaponnum=0;
  396.         self.weapon = new;
  397.     }
  398. };
  399.  
  400. /*
  401. =============
  402. weapon_touch
  403. =============
  404. */
  405. float() W_BestWeapon;
  406.  
  407. void() weapon_touch =
  408. {
  409.     local   float   hadammo, best, new, old;
  410.     local   entity  stemp;
  411.     local   float   leave;
  412.  
  413.     if (!(other.flags & FL_CLIENT))
  414.         return;
  415.  
  416. // if the player was using his best weapon, change up to the new one if better          
  417.     stemp = self;
  418.     self = other;
  419.     best = W_BestWeapon();
  420.     self = stemp;
  421.  
  422.     if (deathmatch == 2 || coop)
  423.         leave = 1;
  424.     else
  425.         leave = 0;
  426.     
  427.     if (self.classname == "weapon_nailgun")
  428.     {
  429.         if (leave && (other.items & IT_NAILGUN) )
  430.             return;
  431.         hadammo = other.ammo_nails;                     
  432.         new = IT_NAILGUN;
  433.         other.ammo_nails = other.ammo_nails + 30;
  434.     }
  435.     else if (self.classname == "weapon_supernailgun")
  436.     {
  437.         new = IT_SUPER_NAILGUN;
  438.         if (leave && (other.items & IT_SUPER_NAILGUN) )
  439.             new = 0;
  440.         else
  441.         {
  442.             other.ammo_nails = other.ammo_nails + 30;
  443.             hadammo = other.ammo_rockets;                   
  444.         }
  445.     }
  446.     else if (self.classname == "weapon_supershotgun")
  447.     {
  448.         if (leave && (other.items & IT_SUPER_SHOTGUN) )
  449.             return;
  450.         hadammo = other.ammo_rockets;                   
  451.         new = IT_SUPER_SHOTGUN;
  452.         other.ammo_shells = other.ammo_shells + 5;
  453.     }
  454.     else if (self.classname == "weapon_rocketlauncher")
  455.     {
  456.         if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  457.             return;
  458.         hadammo = other.ammo_rockets;                   
  459.         new = IT_ROCKET_LAUNCHER;
  460.         other.ammo_rockets = other.ammo_rockets + 5;
  461.     }
  462.     else if (self.classname == "weapon_grenadelauncher")
  463.     {
  464.         if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  465.             return;
  466.         hadammo = other.ammo_rockets;                   
  467.         new = IT_GRENADE_LAUNCHER;
  468.         other.ammo_rockets = other.ammo_rockets + 5;
  469.     }
  470.     else if (self.classname == "weapon_lightning")
  471.     {
  472.         new = IT_LIGHTNING;
  473.         if (leave && (other.items & IT_LIGHTNING))
  474.             new = 0;
  475.         else
  476.         {
  477.             other.ammo_cells = other.ammo_cells + 15;
  478.             hadammo = other.ammo_rockets;
  479.         }
  480.     }
  481.     else
  482.         objerror ("weapon_touch: unknown classname");
  483.  
  484.     sprint (other, "You got the ");
  485.     sprint (other, self.netname);
  486.     sprint (other, "\n");
  487. // weapon touch sound
  488.     sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  489.     stuffcmd (other, "bf\n");
  490.  
  491.     bound_other_ammo ();
  492.  
  493. // change to the weapon
  494.     old = other.items;
  495.     other.items = other.items | new;
  496.     stemp = self;
  497.     self = other;
  498.  
  499.     if (!deathmatch){
  500.         if (self.weapon!=new) self.weaponnum=0;
  501.         self.weapon = new;
  502.     } else
  503.         Deathmatch_Weapon (old, new);
  504.  
  505.     W_SetCurrentAmmo();
  506.  
  507.     self = stemp;
  508.  
  509.     if (leave)
  510.         return;
  511.  
  512. // remove it in single player, or setup for respawning in deathmatch
  513.     self.model = string_null;
  514.     self.solid = SOLID_NOT;
  515.     if (deathmatch != 0 && deathmatch!=2)
  516.         self.nextthink = time + 30;
  517.     self.think = SUB_regen;
  518.     
  519.     activator = other;
  520.     SUB_UseTargets();                               // fire all targets / killtargets
  521. };
  522.  
  523.  
  524. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  525. */
  526.  
  527. void() weapon_supershotgun =
  528. {
  529.     precache_model ("progs/g_shot.mdl");
  530.     setmodel (self, "progs/g_shot.mdl");
  531.     self.weapon = IT_SUPER_SHOTGUN;
  532.     self.netname = "Double-barrelled Shotgun";
  533.     self.touch = weapon_touch;
  534.     setsize (self, '-16 -16 0', '16 16 56');
  535.     StartItem ();
  536. };
  537.  
  538. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  539. */
  540.  
  541. void() weapon_nailgun =
  542. {
  543.     precache_model ("progs/g_nail.mdl");
  544.     setmodel (self, "progs/g_nail.mdl");
  545.     self.weapon = IT_NAILGUN;
  546.     self.netname = "nailgun";
  547.     self.touch = weapon_touch;
  548.     setsize (self, '-16 -16 0', '16 16 56');
  549.     StartItem ();
  550. };
  551.  
  552. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  553. */
  554.  
  555. void() weapon_supernailgun =
  556. {
  557.     precache_model ("progs/g_nail2.mdl");
  558.     setmodel (self, "progs/g_nail2.mdl");
  559.     self.weapon = IT_SUPER_NAILGUN;
  560.     self.netname = "Super Nailgun";
  561.     self.touch = weapon_touch;
  562.     setsize (self, '-16 -16 0', '16 16 56');
  563.     StartItem ();
  564. };
  565.  
  566. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  567. */
  568.  
  569. void() weapon_grenadelauncher =
  570. {
  571.     precache_model ("progs/g_rock.mdl");
  572.     setmodel (self, "progs/g_rock.mdl");
  573.     self.weapon = 3;
  574.     self.netname = "Grenade Launcher";
  575.     self.touch = weapon_touch;
  576.     setsize (self, '-16 -16 0', '16 16 56');
  577.     StartItem ();
  578. };
  579.  
  580. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  581. */
  582.  
  583. void() weapon_rocketlauncher =
  584. {
  585.     precache_model ("progs/g_rock2.mdl");
  586.     setmodel (self, "progs/g_rock2.mdl");
  587.     self.weapon = 3;
  588.     self.netname = "Rocket Launcher";
  589.     self.touch = weapon_touch;
  590.     setsize (self, '-16 -16 0', '16 16 56');
  591.     StartItem ();
  592. };
  593.  
  594.  
  595. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  596. */
  597.  
  598. void() weapon_lightning =
  599. {
  600.     precache_model ("progs/g_light.mdl");
  601.     setmodel (self, "progs/g_light.mdl");
  602.     self.weapon = 3;
  603.     self.netname = "Thunderbolt";
  604.     self.touch = weapon_touch;
  605.     setsize (self, '-16 -16 0', '16 16 56');
  606.     StartItem ();
  607. };
  608.  
  609.  
  610. /*
  611. ===============================================================================
  612.  
  613. AMMO
  614.  
  615. ===============================================================================
  616. */
  617.  
  618. void() ammo_touch =
  619. {
  620. local entity    stemp;
  621. local float             best;
  622.  
  623.     if (other.classname != "player")
  624.         return;
  625.     if (other.health <= 0)
  626.         return;
  627.  
  628. // if the player was using his best weapon, change up to the new one if better          
  629.     stemp = self;
  630.     self = other;
  631.     best = W_BestWeapon();
  632.     self = stemp;
  633.  
  634.  
  635. // shotgun
  636.     if (self.weapon == 1)
  637.     {
  638.         if (other.ammo_shells >= 100)
  639.             return;
  640.         other.ammo_shells = other.ammo_shells + self.aflag;
  641.     }
  642.  
  643. // spikes
  644.     if (self.weapon == 2)
  645.     {
  646.         if (other.ammo_nails >= 200)
  647.             return;
  648.         other.ammo_nails = other.ammo_nails + self.aflag;
  649.     }
  650.  
  651. //      rockets
  652.     if (self.weapon == 3)
  653.     {
  654.         if (other.ammo_rockets >= 100)
  655.             return;
  656.         other.ammo_rockets = other.ammo_rockets + self.aflag;
  657.     }
  658.  
  659. //      cells
  660.     if (self.weapon == 4)
  661.     {
  662.         if (other.ammo_cells >= 200)
  663.             return;
  664.         other.ammo_cells = other.ammo_cells + self.aflag;
  665.     }
  666.  
  667.     //bound_other_ammo ();
  668.     
  669.     sprint (other, "You got the ");
  670.     sprint (other, self.netname);
  671.     sprint (other, "\n");
  672. // ammo touch sound
  673.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  674.     stuffcmd (other, "bf\n");
  675.  
  676. // change to a better weapon if appropriate
  677.  
  678.  
  679. if ( other.weapon == best)
  680.     {
  681.         stemp = self;
  682.         self = other;
  683.         self.weapon = W_BestWeapon();
  684.         W_SetCurrentAmmo ();
  685.         self = stemp;
  686.     }
  687.  
  688. // if changed current ammo, update it
  689.     stemp = self;
  690.     self = other;
  691.     W_SetCurrentAmmo();
  692.     self = stemp;
  693.  
  694. // remove it in single player, or setup for respawning in deathmatch
  695.     self.model = string_null;
  696.     self.solid = SOLID_NOT;
  697.     if (deathmatch != 0 && deathmatch!=2)
  698.         self.nextthink = time + 30;
  699.     self.think = SUB_regen;
  700.  
  701.     activator = other;
  702.     SUB_UseTargets();                               // fire all targets / killtargets
  703. };
  704.  
  705.  
  706.  
  707.  
  708. float WEAPON_BIG2 = 1;
  709.  
  710. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  711. */
  712.  
  713. void() item_shells =
  714. {
  715.     self.touch = ammo_touch;
  716.  
  717.     if (self.spawnflags & WEAPON_BIG2)
  718.     {
  719.         precache_model ("maps/b_shell1.bsp");
  720.         setmodel (self, "maps/b_shell1.bsp");
  721.         self.aflag = 40;
  722.     }
  723.     else
  724.     {
  725.         precache_model ("maps/b_shell0.bsp");
  726.         setmodel (self, "maps/b_shell0.bsp");
  727.         self.aflag = 20;
  728.     }
  729.     self.weapon = 1;
  730.     self.netname = "shells";
  731.     setsize (self, '0 0 0', '32 32 56');
  732.     StartItem ();
  733. };
  734.  
  735. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  736. */
  737.  
  738. void() item_spikes =
  739. {
  740.     self.touch = ammo_touch;
  741.  
  742.     if (self.spawnflags & WEAPON_BIG2)
  743.     {
  744.         precache_model ("maps/b_nail1.bsp");
  745.         setmodel (self, "maps/b_nail1.bsp");
  746.         self.aflag = 50;
  747.     }
  748.     else
  749.     {
  750.         precache_model ("maps/b_nail0.bsp");
  751.         setmodel (self, "maps/b_nail0.bsp");
  752.         self.aflag = 25;
  753.     }
  754.     self.weapon = 2;
  755.     self.netname = "nails";
  756.     setsize (self, '0 0 0', '32 32 56');
  757.     StartItem ();
  758. };
  759.  
  760. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  761. */
  762.  
  763. void() item_rockets =
  764. {
  765.     self.touch = ammo_touch;
  766.  
  767.     if (self.spawnflags & WEAPON_BIG2)
  768.     {
  769.         precache_model ("maps/b_rock1.bsp");
  770.         setmodel (self, "maps/b_rock1.bsp");
  771.         self.aflag = 10;
  772.     }
  773.     else
  774.     {
  775.         precache_model ("maps/b_rock0.bsp");
  776.         setmodel (self, "maps/b_rock0.bsp");
  777.         self.aflag = 5;
  778.     }
  779.     self.weapon = 3;
  780.     self.netname = "rockets";
  781.     setsize (self, '0 0 0', '32 32 56');
  782.     StartItem ();
  783. };
  784.  
  785.  
  786. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  787. */
  788.  
  789. void() item_cells =
  790. {
  791.     self.touch = ammo_touch;
  792.  
  793.     if (self.spawnflags & WEAPON_BIG2)
  794.     {
  795.         precache_model ("maps/b_batt1.bsp");
  796.         setmodel (self, "maps/b_batt1.bsp");
  797.         self.aflag = 12;
  798.     }
  799.     else
  800.     {
  801.         precache_model ("maps/b_batt0.bsp");
  802.         setmodel (self, "maps/b_batt0.bsp");
  803.         self.aflag = 6;
  804.     }
  805.     self.weapon = 4;
  806.     self.netname = "cells";
  807.     setsize (self, '0 0 0', '32 32 56');
  808.     StartItem ();
  809. };
  810.  
  811.  
  812. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  813. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  814. */
  815.  
  816. float WEAPON_SHOTGUN = 1;
  817. float WEAPON_ROCKET = 2;
  818. float WEAPON_SPIKES = 4;
  819. float WEAPON_BIG = 8;
  820. void() item_weapon =
  821. {
  822.     self.touch = ammo_touch;
  823.  
  824.     if (self.spawnflags & WEAPON_SHOTGUN)
  825.     {
  826.         if (self.spawnflags & WEAPON_BIG)
  827.         {
  828.             precache_model ("maps/b_shell1.bsp");
  829.             setmodel (self, "maps/b_shell1.bsp");
  830.             self.aflag = 40;
  831.         }
  832.         else
  833.         {
  834.             precache_model ("maps/b_shell0.bsp");
  835.             setmodel (self, "maps/b_shell0.bsp");
  836.             self.aflag = 20;
  837.         }
  838.         self.weapon = 1;
  839.         self.netname = "shells";
  840.     }
  841.  
  842.     if (self.spawnflags & WEAPON_SPIKES)
  843.     {
  844.         if (self.spawnflags & WEAPON_BIG)
  845.         {
  846.             precache_model ("maps/b_nail1.bsp");
  847.             setmodel (self, "maps/b_nail1.bsp");
  848.             self.aflag = 40;
  849.         }
  850.         else
  851.         {
  852.             precache_model ("maps/b_nail0.bsp");
  853.             setmodel (self, "maps/b_nail0.bsp");
  854.             self.aflag = 20;
  855.         }
  856.         self.weapon = 2;
  857.         self.netname = "spikes";
  858.     }
  859.  
  860.     if (self.spawnflags & WEAPON_ROCKET)
  861.     {
  862.         if (self.spawnflags & WEAPON_BIG)
  863.         {
  864.             precache_model ("maps/b_rock1.bsp");
  865.             setmodel (self, "maps/b_rock1.bsp");
  866.             self.aflag = 10;
  867.         }
  868.         else
  869.         {
  870.             precache_model ("maps/b_rock0.bsp");
  871.             setmodel (self, "maps/b_rock0.bsp");
  872.             self.aflag = 5;
  873.         }
  874.         self.weapon = 3;
  875.         self.netname = "rockets";
  876.     }
  877.     
  878.     setsize (self, '0 0 0', '32 32 56');
  879.     StartItem ();
  880. };
  881.  
  882.  
  883. /*
  884. ===============================================================================
  885.  
  886. KEYS
  887.  
  888. ===============================================================================
  889. */
  890.  
  891. void() key_touch =
  892. {
  893. local entity    stemp;
  894. local float             best;
  895.  
  896.     if (other.classname != "player")
  897.         return;
  898.     if (other.health <= 0)
  899.         return;
  900.     if (other.items & self.items)
  901.         return;
  902.  
  903.     sprint (other, "You got the ");
  904.     sprint (other, self.netname);
  905.     sprint (other,"\n");
  906.  
  907.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  908.     stuffcmd (other, "bf\n");
  909.     other.items = other.items | self.items;
  910.  
  911.     if (!coop)
  912.     {       
  913.         self.solid = SOLID_NOT;
  914.         self.model = string_null;
  915.     }
  916.  
  917.     activator = other;
  918.     SUB_UseTargets();                               // fire all targets / killtargets
  919. };
  920.  
  921.  
  922. void() key_setsounds =
  923. {
  924.     if (world.worldtype == 0)
  925.     {
  926.         precache_sound ("misc/medkey.wav");
  927.         self.noise = "misc/medkey.wav";
  928.     }
  929.     if (world.worldtype == 1)
  930.     {
  931.         precache_sound ("misc/runekey.wav");
  932.         self.noise = "misc/runekey.wav";
  933.     }
  934.     if (world.worldtype == 2)
  935.     {
  936.         precache_sound2 ("misc/basekey.wav");
  937.         self.noise = "misc/basekey.wav";
  938.     }
  939. };
  940.  
  941. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  942. SILVER key
  943. In order for keys to work
  944. you MUST set your maps
  945. worldtype to one of the
  946. following:
  947. 0: medieval
  948. 1: metal
  949. 2: base
  950. */
  951.  
  952. void() item_key1 =
  953. {
  954.     if (world.worldtype == 0)
  955.     {
  956.         precache_model ("progs/w_s_key.mdl");
  957.         setmodel (self, "progs/w_s_key.mdl");
  958.         self.netname = "silver key";
  959.     }
  960.     else if (world.worldtype == 1)
  961.     {
  962.         precache_model ("progs/m_s_key.mdl");
  963.         setmodel (self, "progs/m_s_key.mdl");
  964.         self.netname = "silver runekey";
  965.     }
  966.     else if (world.worldtype == 2)
  967.     {
  968.         precache_model2 ("progs/b_s_key.mdl");
  969.         setmodel (self, "progs/b_s_key.mdl");
  970.         self.netname = "silver keycard";
  971.     }
  972.     key_setsounds();
  973.     self.touch = key_touch;
  974.     self.items = IT_KEY1;
  975.     setsize (self, '-16 -16 -24', '16 16 32');
  976.     StartItem ();
  977. };
  978.  
  979. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  980. GOLD key
  981. In order for keys to work
  982. you MUST set your maps
  983. worldtype to one of the
  984. following:
  985. 0: medieval
  986. 1: metal
  987. 2: base
  988. */
  989.  
  990. void() item_key2 =
  991. {
  992.     if (world.worldtype == 0)
  993.     {
  994.         precache_model ("progs/w_g_key.mdl");
  995.         setmodel (self, "progs/w_g_key.mdl");
  996.         self.netname = "gold key";
  997.     }
  998.     if (world.worldtype == 1)
  999.     {
  1000.         precache_model ("progs/m_g_key.mdl");
  1001.         setmodel (self, "progs/m_g_key.mdl");
  1002.         self.netname = "gold runekey";
  1003.     }
  1004.     if (world.worldtype == 2)
  1005.     {
  1006.         precache_model2 ("progs/b_g_key.mdl");
  1007.         setmodel (self, "progs/b_g_key.mdl");
  1008.         self.netname = "gold keycard";
  1009.     }
  1010.     key_setsounds();
  1011.     self.touch = key_touch;
  1012.     self.items = IT_KEY2;
  1013.     setsize (self, '-16 -16 -24', '16 16 32');
  1014.     StartItem ();
  1015. };
  1016.  
  1017.  
  1018.  
  1019. /*
  1020. ===============================================================================
  1021.  
  1022. END OF LEVEL RUNES
  1023.  
  1024. ===============================================================================
  1025. */
  1026.  
  1027. void() sigil_touch =
  1028. {
  1029. local entity    stemp;
  1030. local float             best;
  1031.  
  1032.     if (other.classname != "player")
  1033.         return;
  1034.     if (other.health <= 0)
  1035.         return;
  1036.  
  1037.     centerprint (other, "You got the rune!");
  1038.  
  1039.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1040.     stuffcmd (other, "bf\n");
  1041.     self.solid = SOLID_NOT;
  1042.     self.model = string_null;
  1043.     serverflags = serverflags | (self.spawnflags & 15);
  1044.     self.classname = "";            // so rune doors won't find it
  1045.     
  1046.     activator = other;
  1047.     SUB_UseTargets();                               // fire all targets / killtargets
  1048. };
  1049.  
  1050.  
  1051. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  1052. End of level sigil, pick up to end episode and return to jrstart.
  1053. */
  1054.  
  1055. void() item_sigil =
  1056. {
  1057.     if (!self.spawnflags)
  1058.         objerror ("no spawnflags");
  1059.  
  1060.     precache_sound ("misc/runekey.wav");
  1061.     self.noise = "misc/runekey.wav";
  1062.  
  1063.     if (self.spawnflags & 1)
  1064.     {
  1065.         precache_model ("progs/end1.mdl");
  1066.         setmodel (self, "progs/end1.mdl");
  1067.     }
  1068.     if (self.spawnflags & 2)
  1069.     {
  1070.         precache_model2 ("progs/end2.mdl");
  1071.         setmodel (self, "progs/end2.mdl");
  1072.     }
  1073.     if (self.spawnflags & 4)
  1074.     {
  1075.         precache_model2 ("progs/end3.mdl");
  1076.         setmodel (self, "progs/end3.mdl");
  1077.     }
  1078.     if (self.spawnflags & 8)
  1079.     {
  1080.         precache_model2 ("progs/end4.mdl");
  1081.         setmodel (self, "progs/end4.mdl");
  1082.     }
  1083.     
  1084.     self.touch = sigil_touch;
  1085.     setsize (self, '-16 -16 -24', '16 16 32');
  1086.     StartItem ();
  1087. };
  1088.  
  1089. /*
  1090. ===============================================================================
  1091.  
  1092. POWERUPS
  1093.  
  1094. ===============================================================================
  1095. */
  1096.  
  1097. void() powerup_touch;
  1098.  
  1099.  
  1100. void() powerup_touch =
  1101. {
  1102. local entity    stemp;
  1103. local float             best;
  1104.  
  1105.     if (other.classname != "player")
  1106.         return;
  1107.     if (other.health <= 0)
  1108.         return;
  1109.  
  1110.     sprint (other, "You got the ");
  1111.     sprint (other, self.netname);
  1112.     sprint (other,"\n");
  1113.  
  1114.     if (deathmatch)
  1115.     {
  1116.         self.mdl = self.model;
  1117.         if ((self.classname == "item_artifact_invulnerability") ||
  1118.             (self.classname == "item_artifact_invisibility"))
  1119.             self.nextthink = time + 60*5;
  1120.         else
  1121.             self.nextthink = time + 60;
  1122.  
  1123.         self.think = SUB_regen;        
  1124.     }       
  1125.     sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  1126.     stuffcmd (other, "bf\n");
  1127.     self.solid = SOLID_NOT;
  1128.     other.items = other.items | self.items;
  1129.     self.model = string_null;
  1130.  
  1131. // do the apropriate action
  1132.     if (self.classname == "item_artifact_envirosuit")
  1133.     {
  1134.         other.rad_time = 1;
  1135.         other.radsuit_finished = time + 30;
  1136.     }
  1137.     
  1138.     if (self.classname == "item_artifact_invulnerability")
  1139.     {
  1140.         other.invincible_time = 1;
  1141.         other.invincible_finished = time + 30;
  1142.     }
  1143.     
  1144.     if (self.classname == "item_artifact_invisibility")
  1145.     {
  1146.         other.invisible_time = 1;
  1147.         other.invisible_finished = time + 30;
  1148.     }
  1149.  
  1150.     if (self.classname == "item_artifact_super_damage")
  1151.     {
  1152.         other.super_time = 1;
  1153.         other.super_damage_finished = time + 30;
  1154.     }       
  1155.     activator = other;
  1156.     SUB_UseTargets();                               // fire all targets / killtargets
  1157. };
  1158.  
  1159.  
  1160.  
  1161. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  1162. Player is invulnerable for 30 seconds
  1163. */
  1164. void() item_artifact_invulnerability =
  1165. {
  1166.     self.touch = powerup_touch;
  1167.  
  1168.     precache_model ("progs/invulner.mdl");
  1169.     precache_sound ("items/protect.wav");
  1170.     precache_sound ("items/protect2.wav");
  1171.     precache_sound ("items/protect3.wav");
  1172.     self.noise = "items/protect.wav";
  1173.     setmodel (self, "progs/invulner.mdl");
  1174.     self.netname = "Pentagram of Protection";
  1175.     self.items = IT_INVULNERABILITY;
  1176.     setsize (self, '-16 -16 -24', '16 16 32');
  1177.     StartItem ();
  1178. };
  1179.  
  1180. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  1181. Player takes no damage from water or slime for 30 seconds
  1182. */
  1183. void() item_artifact_envirosuit =
  1184. {
  1185.     self.touch = powerup_touch;
  1186.  
  1187.     precache_model ("progs/suit.mdl");
  1188.     precache_sound ("items/suit.wav");
  1189.     precache_sound ("items/suit2.wav");
  1190.     self.noise = "items/suit.wav";
  1191.     setmodel (self, "progs/suit.mdl");
  1192.     self.netname = "Biosuit";
  1193.     self.items = IT_SUIT;
  1194.     setsize (self, '-16 -16 -24', '16 16 32');
  1195.     StartItem ();
  1196. };
  1197.  
  1198.  
  1199. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  1200. Player is invisible for 30 seconds
  1201. */
  1202. void() item_artifact_invisibility =
  1203. {
  1204.     self.touch = powerup_touch;
  1205.  
  1206.     precache_model ("progs/invisibl.mdl");
  1207.     precache_sound ("items/inv1.wav");
  1208.     precache_sound ("items/inv2.wav");
  1209.     precache_sound ("items/inv3.wav");
  1210.     self.noise = "items/inv1.wav";
  1211.     setmodel (self, "progs/invisibl.mdl");
  1212.     self.netname = "Ring of Shadows";
  1213.     self.items = IT_INVISIBILITY;
  1214.     setsize (self, '-16 -16 -24', '16 16 32');
  1215.     StartItem ();
  1216. };
  1217.  
  1218.  
  1219. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  1220. The next attack from the player will do 4x damage
  1221. */
  1222. void() item_artifact_super_damage =
  1223. {
  1224.     self.touch = powerup_touch;
  1225.  
  1226.     precache_model ("progs/quaddama.mdl");
  1227.     precache_sound ("items/damage.wav");
  1228.     precache_sound ("items/damage2.wav");
  1229.     precache_sound ("items/damage3.wav");
  1230.     self.noise = "items/damage.wav";
  1231.     setmodel (self, "progs/quaddama.mdl");
  1232.     self.netname = "Quad Damage";
  1233.     self.items = IT_QUAD;
  1234.     setsize (self, '-16 -16 -24', '16 16 32');
  1235.     StartItem ();
  1236. };
  1237.  
  1238.  
  1239.  
  1240. /*
  1241. ===============================================================================
  1242.  
  1243. PLAYER BACKPACKS
  1244.  
  1245. ===============================================================================
  1246. */
  1247.  
  1248. void() BackpackTouch = {
  1249.     local string    s;
  1250.     local    float    best, old, new;
  1251.     local        entity    stemp;
  1252.     
  1253.     if (other.classname != "player")
  1254.         return;
  1255.     if (other.health <= 0)
  1256.         return;
  1257. // change weapons
  1258.     other.ammo_shells = other.ammo_shells + self.ammo_shells;
  1259.     other.ammo_nails = other.ammo_nails + self.ammo_nails;
  1260.     other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
  1261.     other.ammo_cells = other.ammo_cells + self.ammo_cells;
  1262.  
  1263.     old = other.items;
  1264.     new = self.items;
  1265.     other.items = other.items | new;
  1266.  
  1267. // if the player was using his best weapon, change up to the new one if better        
  1268.     stemp = self;
  1269.     self = other;
  1270.     best = W_BestWeapon();
  1271.     self = stemp;
  1272.  
  1273.     
  1274.     bound_other_ammo ();
  1275.  
  1276.     sprint (other, "You get ");
  1277.  
  1278.     if (self.ammo_shells)
  1279.     {
  1280.         s = ftos(self.ammo_shells);
  1281.         sprint (other, s);
  1282.         sprint (other, " shells  ");
  1283.     }
  1284.     if (self.ammo_nails)
  1285.     {
  1286.         s = ftos(self.ammo_nails);
  1287.         sprint (other, s);
  1288.         sprint (other, " nails ");
  1289.     }
  1290.     if (self.ammo_rockets)
  1291.     {
  1292.         s = ftos(self.ammo_rockets);
  1293.         sprint (other, s);
  1294.         sprint (other, " rockets  ");
  1295.     }
  1296.     if (self.ammo_cells)
  1297.     {
  1298.         s = ftos(self.ammo_cells);
  1299.         sprint (other, s);
  1300.         sprint (other, " cells  ");
  1301.     }
  1302.     
  1303.     sprint (other, "\n");
  1304. // backpack touch sound
  1305.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1306.     stuffcmd (other, "bf\n");
  1307.  
  1308. // remove the backpack, change self to the player
  1309.     remove(self);
  1310.     self = other;
  1311.  
  1312. // change to the weapon
  1313.     if(best < stemp.items){
  1314.         if (!deathmatch) self.weapon = best;
  1315.         else Deathmatch_Weapon (old, new);
  1316.     }
  1317.  
  1318.     W_SetCurrentAmmo ();
  1319. };
  1320.  
  1321. /*
  1322. ===============
  1323. DropBackpack
  1324. ===============
  1325. */
  1326. void() DropBackpack =
  1327. {
  1328.     local entity    item;
  1329.  
  1330.     if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells))
  1331.         return; // nothing in it
  1332.  
  1333.     item = spawn();
  1334.     item.origin = self.origin - '0 0 24';
  1335.     
  1336.     item.items = self.weapon;
  1337.  
  1338.     item.ammo_shells = self.ammo_shells;
  1339.     item.ammo_nails = self.ammo_nails;
  1340.     item.ammo_rockets = self.ammo_rockets;
  1341.     item.ammo_cells = self.ammo_cells;
  1342.  
  1343.     item.velocity_z = 300;
  1344.     item.velocity_x = -100 + (random() * 200);
  1345.     item.velocity_y = -100 + (random() * 200);
  1346.     
  1347.     item.flags = FL_ITEM;
  1348.     item.solid = SOLID_TRIGGER;
  1349.     item.movetype = MOVETYPE_TOSS;
  1350.     setmodel (item, "progs/backpack.mdl");
  1351.     setsize (item, '-16 -16 0', '16 16 56');
  1352.     item.touch = BackpackTouch;
  1353.     
  1354.     item.nextthink = time + 120;    // remove after 2 minutes
  1355.     item.think = SUB_Remove;
  1356. };
  1357.  
  1358.